package org.springblade.modules.enterprise.api;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.modules.enterprise.entity.EsmsCry;
import org.springblade.modules.enterprise.entity.EsmsTalentService;
import org.springblade.modules.enterprise.service.IEsmsTalentServiceService;
import org.springblade.modules.enterprise.vo.EsmsTalentServiceVO;
import org.springblade.modules.enterprise.wrapper.EsmsTalentServiceWrapper;
import org.springblade.modules.system.service.IDictService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
@RequestMapping("/enterprise/service-info")
@Api(value = "服务信息", tags = "(api)服务信息")
public class ServiceApi {

	private final IEsmsTalentServiceService serviceService;
	private final IDictService dictService;

	/**
	 * 详情
	 */
	@GetMapping("/detail")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入esmsTalentService")
	public R<EsmsTalentServiceVO> detail(EsmsTalentService esmsTalentService) {
		EsmsTalentService detail = serviceService.getOne(Condition.getQueryWrapper(esmsTalentService));
		return R.data(EsmsTalentServiceWrapper.build().entityVO(detail));
	}

	/**
	 * 详情
	 */
	@GetMapping("/detailForAPP")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = "详情", notes = "传入esmsCry")
	public R<EsmsTalentService> detailForAPP(EsmsTalentService esmsTalentService) {
		QueryWrapper<EsmsTalentService> esms=new QueryWrapper<>();
		esms.eq("id",esmsTalentService.getId());
		EsmsTalentService detail = serviceService.getOne(esms);
		return R.data(detail);
	}
	/**
	 * 分页 人才服务需求表
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 2)
	@ApiOperation(value = "分页", notes = "传入esmsTalentService")
	public R<IPage<EsmsTalentServiceVO>> list(EsmsTalentService esmsTalentService, Query query) {
		IPage<EsmsTalentService> pages = serviceService.page(Condition.getPage(query), Condition.getQueryWrapper(esmsTalentService));
		return R.data(EsmsTalentServiceWrapper.build().pageVO(pages));
	}


	/**
	 * 自定义分页 人才服务需求表
	 */
	@GetMapping("/page")
	@ApiOperationSupport(order = 3)
	@ApiOperation(value = "分页", notes = "传入esmsTalentService")
	public R<IPage<EsmsTalentServiceVO>> page(EsmsTalentServiceVO esmsTalentService, Query query) {
		IPage<EsmsTalentServiceVO> pages = serviceService.selectEsmsTalentServicePage(Condition.getPage(query), esmsTalentService);
		return R.data(pages);
	}
}
